package SpringBoot.spring_boot_starter_websocket.D01_获取服务器时间.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 *
 *
 * @author 周成功
 *
 */
@EnableWebMvc  
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
    @Override  
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String location = this.getClass().getPackage().getName();
        location = location.substring(0, location.lastIndexOf('.'));
        location = "/" + location.replaceAll("\\.", "/") + "/web/";
        registry.addResourceHandler("/**")  // "/html/**"
                .addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+location);  
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+"/META-INF/resources/webjars/");  
        super.addResourceHandlers(registry);
    }
}
